package work3_15;

/**
 * 设计Account类如下：
 * private long id;private double balabce;private String password;
 * 要求完善设计，使得该Account对象能够自动分配自增id。给定一个list如下：
 * List list=new ArrayList();
 * list.add(new Account(10.00,"1234"));
 * list.add(new Account(15.00,"5678"));
 * list.add(new Account(0,"1010"));
 * 要求把List的内容放到一个Map中，该Map的键为id,值为相应的Account对象。最后遍历这个Map,
 * 打印所有Account对象的id和余额。
 */
public class Account {
    private long id;
    private double balance;
    private String password;
    private static int num = 1;

    public Account(double balance, String password) {
        this.id = num++;
        this.balance = balance;
        this.password = password;
    }

    @Override
    public String toString() {
        return "Account{" +
                "id=" + id +
                ", balance=" + balance +
                ", password='" + password + '\'' +
                '}';
    }
}

